package com.qf.filter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @author lyx
 * @date 2022/7/7 17:36
 */
@Component
public class Filter2 implements GlobalFilter, Ordered {

    /**
     * 编写业务逻辑 比如授权工作  鉴权工作
     * @param exchange
     * @param chain
     * @return
     */
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
      //  String token = exchange.getRequest().getQueryParams().getFirst("token");
        System.out.println("-------filter2执行了------------");
        //判断token是否为空

        return chain.filter(exchange);
    }

    @Override
    public int getOrder() {
        return 2;
    }
}
